package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.ProductImageTextMapperExt;
import com.lzy.product.dtos.ProductImageTextDto;
import com.lzy.product.entity.ProductImageText;
import com.lzy.product.service.ProductImageTextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2017/12/2.
 */
@Service
public class ProductImageTextServiceImpl implements ProductImageTextService {

    @Autowired
    ProductImageTextMapperExt productImageTextMapperExt;

    @Override
    public Long insert(ProductImageTextDto dto) {
        ProductImageText productImageText = DozerUtils.map(dto, ProductImageText.class);
        return productImageTextMapperExt.insertSelective(productImageText) > 0 ? productImageText.getId() : null;
    }

    @Override
    public Boolean update(ProductImageTextDto dto) {
        return productImageTextMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, ProductImageText.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return productImageTextMapperExt.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public ProductImageTextDto findById(Long id) {
        return DozerUtils.map(productImageTextMapperExt.selectByPrimaryKey(id), ProductImageTextDto.class);
    }

    @Override
    public List<ProductImageTextDto> query(ProductImageTextDto dto) {
        return productImageTextMapperExt.selectList(dto);
    }
}
